'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  router.get('/', controller.home.index);
  router.post('/api/post-test', controller.home.find)

  /**
   * @des home.js
   */
  router.post('/api/login', controller.home.login)
  router.post('/api/register', controller.home.register)

  /**
   * @des goods.js
   * @method [put、delete、post、get]
   * 商品列表
   */

  router.get('/api/findGoods', controller.goods.findGoods)
  router.post('/api/addGoods', controller.goods.addGoods)
  router.delete('/api/deleteGoods/:id', controller.goods.deleteGoods)
  router.put('/api/updateGoods/:id', controller.goods.updateGoods)

  /**
   * @des cart.js
   */

  router.get('/api/findCartList', controller.cart.findCartList)
  router.delete('/api/deleteCartItem/:skuId', controller.cart.deleteCartItem)

  // 加入购物车
  router.get('/api/toCartItem', controller.cart.toCartItem)
  // ++ --
  router.post('/api/updateSkuount', controller.cart.updateSkuount)

  // router.post('/api/addCartItem', controller.cart.addCartItem)
  // router.delete('/api/removeCartItem', controller.cart.removeCartItem)
  router.get('/api/allCartListPrice', controller.cart.allCartListPrice)
  // // detailCartItem
  router.get('/api/detailCartItem', controller.cart.detailCartItem)
};
